﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VSA.Entities;
using VSA.Interfaces.Business;
using VSA.Interfaces.Entities;
using VSA.DataAccess;

namespace VSA.Business
{
    public class Customers : BusinessBase, ICustomers<IList<Customer>>
    {
        public IList<Customer> List(out int numberOfPages,out int numberOfItemsPerPage,int pageNumber)
        {
            IEntity<Customer> customerEntity = GetEntityObject();
            customerEntity.SetUpPageFunctionPrerequisites();
            numberOfPages = customerEntity.NumberOfPages;
            numberOfItemsPerPage = customerEntity.NumberOfItemsPerPage;

            return customerEntity.List(pageNumber);
        }
        public void Update(string CustomerId, string CompanyName)
        {
            Customer custObj = new Customer();
            custObj.CustomerID = CustomerId;
            custObj.CompanyName = CompanyName;

            GetEntityObject().Update(custObj);
        }
        public void Insert(string CustomerId, string CompanyName)
        {
            Customer custObj = new Customer();
            custObj.CustomerID = CustomerId;
            custObj.CompanyName = CompanyName;

            GetEntityObject().Insert(custObj);
        }

        public void Delete(string CustomerId)
        {
            Customer custObj = new Customer();
            custObj.CustomerID = CustomerId;

            GetEntityObject().Delete(custObj);
        }

        private IEntity<Customer> GetEntityObject()
        {
            return (IEntity<Customer>)EntityFactory.CreateEntityObject(EntityEnumeration.Customer, this.DataContext);
        }
    }
}
